<!DOCTYPE html>
<html lang="en"  xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>英雄列表</title>
    <!--  抽取公共头部-->
    <div th:replace="admin/common :: head"></div>
</head>
<body>

<!--抽取公共导航栏-->
<div th:replace="admin/common :: menu(3)"></div>


<div class="m-padded-tb-hugex">
    <div class="ui attached pointing menu">
        <div class="ui container">
            <div class="right menu">
                <a href="#" th:href="@{/admin/hero/append}" class=" item">新增</a>
                <a href="#" class="teal active item">列表</a>
            </div>
        </div>
    </div>
</div>

<br>
<br>
<br>

<!--中间内容-->
<div class="">
    <div class="ui container">
        <div class="ui success message">
            <i class="close icon"></i>
            <div class="" th:text="|提示：${message}|" >提示：操作成功！</div>
        </div>
        <form th:action="@{/admin/hero}" method="post">
            <div class="ui secondary segment form" >
                <div class="inline fields">
                    <div class="field">
                        <input type="text" th:value="${condition.title}" name="title" placeholder="标题">
                    </div>
                    <div class="field">
                        <select name="provinceId">
                            <option th:value="null" th:selected="${condition.provinceId} eq '' ">省份</option>
                            <option class="item" th:selected="${condition.provinceId==province.provinceId}" th:each="province:${provinces}" th:value="${province.provinceId}" th:text="${province.provinceName}" data-value="1"></option>
                        </select>
                    </div>
                    <div class="field">
                        <button type="submit" id="search-btn" class="ui mini teal basic button"><i class="search icon"></i>搜索</button>
                    </div>
                </div>
            </div>
        </form>
        <div id="table-container">
            <table class="ui compact teal table">
                <thead>
                <tr align="center">
                    <th>ID</th>
                    <th>标题</th>
                    <th>省份</th>
                    <th>状态</th>
                    <th>更新时间</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <tr align="center" th:each="hero,statu:${pager.datas}">
                    <td th:text="${statu.count}">1</td>
                    <td th:text="${hero.title}">大圣，此去欲何?</td>
                    <td th:text="${hero.provinceName}">我的故事</td>
                    <td th:text="${hero.flag}">草稿</td>
                    <td th:text="${#dates.format(hero.updateTime,'yyyy-MM-dd HH:mm')}">2020-01-02 05:20</td>
                    <td>
                        <!--th:href="@{/admin/types/{id}/input(id=${type.id})}"-->
                        <a href="#" th:href="@{/admin/hero/modify/{heroId}(heroId=${hero.heroId})}" class="ui mini teal basic button">编辑</a>
                        <a href="#" th:href="@{/admin/hero/delete/{heroId}(heroId=${hero.heroId})}" onclick="return confirm('确定要删除该文章吗？三思啊! 删了可就没了！')" class="ui mini red basic button">删除</a>
                    </td>
                </tr>
                </tbody>
                <tfoot>
                <tr>
                    <th colspan="7">
                        <div class="ui inverted divided stackable grid">
                            <div class="three wide column" align="center">
                                <a th:if="${pager.has_pre}" th:href="@{/admin/hero}" class="item">首页</a>&nbsp;&nbsp;&nbsp;
                                <a th:if="${pager.has_pre}" th:href="@{/admin/hero(page=${pager.page}-1)}" class="item">上一页</a>
                            </div>

                            <div class="ten wide column" align="center">
                                <p>第 <span th:text="${pager.page}"></span> 页，共 <span th:text="${pager.pages}"></span> 页，有 <span th:text="${pager.size}"></span> 篇文章</p>
                            </div>

                            <div class="three wide column" align="center">
                                <a th:if="${pager.has_next}" th:href="@{/admin/hero(page=${pager.page}+1)}" class="item">下一页</a>&nbsp;&nbsp;&nbsp;
                                <a th:if="${pager.has_next}" th:href="@{/admin/hero(page=${pager.last})}" class="item">末页</a>
                            </div>
                        </div>
                        <div align="center">
                            <div align="center">
                                <a href="#" th:href="@{/admin/hero/append}">
                                    <button type="button" class="ui teal button m-mobile-wide m-margin-top"><i class="pencil icon"></i>新增</button>
                                </a>
                            </div>
                        </div>
                    </th>
                </tr>
                </tfoot>
            </table>
        </div>
    </div>
</div>


<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>


<!--抽取公共底部栏-->
<div th:replace="admin/common :: #footer"></div>

<!--抽取公共js-->
<div th:replace="admin/common :: #js"></div>

<script>
    $('.menu.toggle').click(function () {
        $('.m-item').toggleClass('m-mobile-hide');
    });

    $('.ui.dropdown').dropdown({
        on: 'hover'
    });

    //消息提示关闭初始化
    $('.message .close')
        .on('click', function () {
            $(this)
                .closest('.message')
                .transition('fade');
        });

    $('#clear-btn')
        .on('click', function () {
            $('.ui.type.dropdown')
                .dropdown('clear');
        });

    function page(obj) {
        $("[name='page']").val($(obj).data("page"));
        loaddata();
    }

    $("#search-btn").click(function () {
        $("[name='page']").val(0);
        loaddata();
    });

    function loaddata() {
        $("#table-container").load(/*[[@{/admin/blogs/search}]]*/"/admin/blogs/search", {
            title: $("[name='title']").val(),
            typeId: $("[name='typeId']").val(),
            page: $("[name='page']").val()
        });
    }
</script>


</body>
</html>